{include file="public/header" /}

<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
                            <legend>条件搜索</legend>
                            <form class="layui-form layui-form-pane form-search">
                                <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">排序类型</label>
                                    <div class="layui-input-inline">
                                        <select name="sort" lay-filter="leixin">
                                            <option value="">默认排序</option>
                                            <option value="1" {if !empty(input('get.sort')) &&
                                                input('get.sort')==1}selected{/if}>按添加时间排序</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">内容类型</label>
                                    <div class="layui-input-inline">
                                        <select name="leixin" lay-filter="leixin">
                                            <option value="">选择类型</option>
                                            <option value="1" {if !empty(input('get.leixin')) &&
                                                input('get.leixin')==1}selected{/if}>公告</option>
                                            <option value="2" {if !empty(input('get.leixin')) &&
                                                input('get.leixin')==2}selected{/if}>学习中心</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline fltype" {if empty(input('get.leixin')) ||
                                    input('get.leixin')!=2}style="display: none;" {/if}>
                                    <label class="layui-form-label">细分类型</label>
                                    <div class="layui-input-inline">
                                        <select name="fltype" lay-filter="fltype">
                                            <option value="">选择细分类型</option>
                                            <option value="1" {if !empty(input('get.fltype')) &&
                                                input('get.fltype')==1}selected{/if}>规章制度</option>
                                            <option value="2" {if !empty(input('get.fltype')) &&
                                                input('get.fltype')==2}selected{/if}>业务知识</option>
                                            <option value="3" {if !empty(input('get.fltype')) &&
                                                input('get.fltype')==3}selected{/if}>资料架</option>
                                            <option value="4" {if !empty(input('get.fltype')) &&
                                                input('get.fltype')==4}selected{/if}>视频学习</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">可查看人员</label>
                                    <div class="layui-input-inline">
                                        <select name="type">
                                            <option value="">选择人员类型</option>
                                            {foreach $typelist as $k => $v}
                                            <option value="{$k}" {if !empty(input('get.type')) &&
                                                input('get.type')==$k}selected{/if}>
                                                {$v|default=''}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">标题搜索</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="title" placeholder="标题搜索备注"
                                            value="{:input('get.title')}" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline">
                                    <button class="layui-btn layui-btn-normal" lay-submit=""
                                        lay-filter="sreach">搜索</button>
                                </div>
                            </form>
                        </fieldset>
                    </div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <button class="layui-btn layui-bg-cyan layui-btn-sm"
                            onclick="open_add('添加','annous_edit')">添加</button>
                        共有数据：<strong id="count">{$list->total()}</strong> 条

                    </div>
                    <div class="layui-table-body layui-table-main">
                        <table class="layui-table">
                            <thead>
                                <tr>
                                    <th>
                                        <div class="layui-table-cell">ID</div>
                                    </th>
                                    <th>
                                        <div class="layui-table-cell">标题</div>
                                    </th>
                                    <th>
                                        <div class="layui-table-cell">类型</div>
                                    </th>
                                    <th>
                                        <div class="layui-table-cell">可见人员</div>
                                    </th>
                                    <th>
                                        <div class="layui-table-cell">发布日期</div>
                                    </th>
                                    <th>
                                        <div class="layui-table-cell">结束日期</div>
                                    </th>
                                    <th>
                                        <div class="layui-table-cell">操作</div>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                {foreach $list as $v}
                                <tr>
                                    <td>
                                        <div class="layui-table-cell">{$v.id}</div>
                                    </td>
                                    <td>
                                        <div class="layui-table-cell">{$v.title}</div>
                                    </td>
                                    <td>
                                        <div >
                                            {if $v.leixin == 1}
                                            <a class="layui-btn layui-btn-sm layui-btn-danger">公告</a>
                                            {else}
                                            <a class="layui-btn layui-btn-sm">学习中心</a>
                                            {/if}
                                            <br />
                                            {if $v.sonstype == 1}
                                            <a class="layui-btn layui-btn-sm">督导可见</a>
                                            {elseif $v.sonstype == 2}
                                            <a class="layui-btn layui-btn-sm layui-btn-warm">专员可见</a>
                                            {else}
                                            <!-- <a class="layui-btn layui-btn-sm layui-btn-normal">全员可见</a> -->
                                            {/if}
                                            <br />
                                            {if $v.leixin == 2}
                                            {if $v.fltype == 1}<a class="layui-btn layui-btn-sm">规章制度</a>{/if}
                                            {if $v.fltype == 2}<a
                                                class="layui-btn layui-btn-sm layui-btn-warm">业务知识</a>{/if}
                                            {if $v.fltype == 3}<a
                                                class="layui-btn layui-btn-sm layui-btn-warm">资料架</a>{/if}
                                            {/if}
                                            <br/>
                                            {if $v.fltype == 4}<a
                                                class="layui-btn layui-btn-sm layui-btn-warm">视频学习</a>{/if}
                                        </div>
                                    </td>
                                    <td>
                                        <div style="width: 300px;">{$v.type_text|default=''}</div>
                                    </td>
                                    <td>
                                        <div class="layui-table-cell">{$v.dates}</div>
                                    </td>
                                    <td>
                                        <div class="layui-table-cell">{$v.enddates}</div>
                                    </td>
                                    <td class="layui-table-col-special">
                                        <div>
                                            <a title="编辑" onclick="open_add('编辑','/system/annous_edit?id={$v.id}')"
                                                href="javascript:;" class="layui-btn layui-btn-sm">
                                                编辑
                                            </a>
                                            <a title="已读人员情况"
                                                onclick="open_add('查看已读人员情况','/system/annous_user?id={$v.id}')"
                                                href="javascript:;" class="layui-btn layui-btn-sm">
                                                查看人员查看情况
                                            </a>
                                            <br />
                                            <a title="重置已读" onclick="open_dels2(this,'/system/annous_reset','{$v.id}')"
                                                href="javascript:;" class="layui-btn-danger layui-btn layui-btn-sm">
                                                重置已读(已查看的会重新通知)
                                            </a>
                                            <br />
                                            <a title="删除" onclick="open_dels(this,'/system/annous_del','{$v.id}')"
                                                href="javascript:;" class="layui-btn-danger layui-btn layui-btn-sm">
                                                删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}

                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {$list->render()|raw}
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
    {include file="public/footer"}
    <script>
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;
            form.on('select(leixin)', function (data) {
                if (data.value == 2) {
                    $('.fltype').show();
                } else {
                    $('.fltype').hide();
                    $("select[name='fltype']").val(0);
                }
            });
            //监听省份选择
            form.on('select(province)', function (data) {
                if (!data.value) {
                    $('select[name="city"]').html('');
                    $('select[name="area"]').html('');
                    $('select[name="street"]').html('');
                    form.render();
                    return false;
                }
                //发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 2 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="">请选择城市</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.area_code;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="city"]').html(str);
                            $('select[name="area"]').html('');
                            $('select[name="street"]').html('');
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
            //监听城市选择
            form.on('select(city)', function (data) {
                if (!data.value) {
                    $('select[name="area"]').html('');
                    $('select[name="street"]').html('');
                    form.render();
                    return false;
                }
                //发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 3 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="">请选择区域</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.area_code;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="area"]').html(str);
                            $('select[name="street"]').html('');
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
            //监听区域选择
            form.on('select(area)', function (data) {
                if (!data.value) {
                    $('select[name="street"]').html('');
                    form.render();
                    return false;
                }
                //发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 4 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="">请选择街道</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.id;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="street"]').html(str);
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>
</body>